/*
 * @Author: zwz
 * @Date: 2023-05-25 10:44:26
 * @LastEditors: zwz
 * @LastEditTime: 2023-06-06 15:41:10
 * @Description: 请填写简介
 */
/* eslint valid-jsdoc: "off" */

'use strict';

/**
 * @param {Egg.EggAppInfo} appInfo app info
 */
module.exports = appInfo => {
    /**
     * built-in config
     * @type {Egg.EggAppConfig}
     **/
    const config = exports = {};

    // use for cookie sign key, should change to your own and keep security
    config.keys = 'Ap38dk30sS3l',
        config.private_key = `-----BEGIN PRIVATE KEY-----
      MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAJ63v6yp7Q6QbReS
      +iHBwsMPbw5GRXcndNyEjePxpu0ySX0taLEYh2GMwdw7Jt9yZIRbvxnM8woYLw1f
      h9noZh6uBrazFVTrM2NTVTRFzwMz004LwZY2s9umETHrmNEh6J7TFqInFwpXgWYl
      yAoO7X3JcyhWi8AUpci8rvWNwhYDAgMBAAECgYA3mshcBWw3ngGaMLPQ/8Dr9YxC
      w/uyMvCOESJkqVSB5Qw5/p6e7KkBU/7W2SJVRg5REJNyxoqfDrntRXqirPiZWb9n
      4+lRw67HB0Dy9IFdFhuWcPpRjmAjQnhQth2WWDINFtpiK3hzy/ASboUsI39zmoeW
      xP3t8/ZFDq2vFnCQAQJBAMu4jFfJlPZF7Me/LZUPsinuvHWsfWR1cdcJXbf3PFte
      TAzngvgzND2C3pR/Hf9VWhjoo39amC6NDHXhETxkLYMCQQDHcrf3jvE6UWyqicgD
      HmJwMjW//03i/odkwVOYRCP2ytgdsZujnyldNPV51H0ATSImsZLLL9/OJPG9lhQV
      Eo2BAkA2FnFsfWDHYhlTjzaS9O/gojn3JCzGl0f6R8pSJZooyAh5BJ6JN08PZcei
      tX1JZWfeZSXDklIFSf2c7nydBBvxAkAA6bmF3JWmGrFQpojP2tfAg7pTQqvsmhWs
      lGX5kHZJruwGVsXLnfLmhlOJVzurQK8jVjTB0VpI60pf/8vfvNIBAkEAwGbApTtc
      sovjwpVptJKTHvuJx+vKbiNanNwXuECZXw2RltReEtEg297ftRdOe0vLtfjPi75y
      MMo/LL547X7hbw==
      -----END PRIVATE KEY-----`,

        config.middleware = [];
    config.sequelize = {
        dialect: 'mysql',
        host: 'localhost',
        port: '3306',
        user: 'root', // 创建数据库时设置用户名
        password: '123456', // 创建数据库时设置的密码
        database: 'fund_rescords',
    };
    // config.cors: {
    //   origin: 'http://localhost:8080',
    //   credentials: true
    // };
    config.mysql = {
        client: {
            host: 'localhost',
            port: '3306', // 数据库的端口号，如果不设置，默认是3306
            user: 'root', // 创建数据库时设置用户名
            password: '123456', // 创建数据库时设置的密码
            database: 'fund_rescords', // 创建的数据库
            //   connectTimeout: 5000, // 连接超时
        },
        app: true,
        agent: false,
    };
    // 安全配置可以不用token就可以访问成功
    config.security = {
        csrf: {
            enable: false,
            // match: '/example',
            // queryName: '_csrf', // 通过 query 传递 CSRF token 的默认字段为 _csrf
            // bodyName: '_csrf', // 通过 body 传递 CSRF token 的默认字段为 _csrf
            // headerName: 'x-csrf-token' // 通过 header 传递 CSRF token 的默认字段为 token
        },
    };
    config.jwt = { // token 密码
        secret: '*******', // 可以自定义
        sign: {	//jwt.sign(***,***,[options,***])方法中，options的默认设置可以在这里配置；
            // 过期时间8小时
            expiresIn: 8 * (60 * 60)   //多少s后过期。actionToken.js中,jwt.sing(plyload,secret,{expiresIn:number})会被合并，调用时设置优先级更高;
        }
    };
    config.view = {
        mapping: {
            '.html': 'ejs',
        },
    };
    // 参数
    config.validate = {
        enable: true,
        package: 'egg-validate',
    };
    // 密码加密
    config.bcrypt = {
        saltRounds: 10,
    };
    config.ejs = {
        delimiter: '$',
    };
    //   配置静态资源文件的
    config.static = {
        // prefix: '/assets/',
    };
    // add your user config here
    const userConfig = {
        myAppName: 'egg',
    };
    return {
        ...config,
        ...userConfig,
    };
};

